$(function () {
    var tbody=window.document.getElementById("tbody-result");
    $.ajax({
        type:'GET',
        dataType:'json',
        url:contextPath+"learner/all",
        success:function (data) {
            // console.log(data.count);
            // console.log(data);
            var str="";
            // var l=data.message.length();
            // console.log(l);
            for (var i=0;i<data.count;i++) {
                // console.log(data.list[i].course_name);
                str += "<tr>" +
                    "<td>" + i + "</td>" +
                    "<td>" + data.list[i].name+"</td>"+
                    "<td>" + data.list[i].phone+ "</td>" +
                    "<td>" + data.list[i].sex + "</td>" +
                    "<td><button onclick='chuanv(this)'>分配视频资源</button><button onclick='chuand(this)'>分配文档资源</button></td>"
                    "</tr>";
            }
            // console.log(str);
            tbody.innerHTML=str;
        }
        ,
        error:function () {
            alert("查询失败")
        }
    })
});
function chuand(r) {
    var table =window.document.getElementById("tbody-result");
    var i= r.parentNode.parentNode.rowIndex-1;
    var ss =new Object();
    ss.name=table.rows[i].cells[1].innerHTML;
    // var data=[];
    // data.push(ss.name);
    window.location.href="documentQuery.html?name="+ss.name;
}
function chuanv(r) {
    var table =window.document.getElementById("tbody-result");
    var i= r.parentNode.parentNode.rowIndex-1;
    var ss =new Object();
    ss.name=table.rows[i].cells[1].innerHTML;
    // var data=[];
    // data.push(ss.name);
    window.location.href="videoQuery.html?name="+ss.name;
}